package com.unicom.projt.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.unicom.projt.R;

/**
 * Created by IntelliJ IDEA.
 * User: Lee
 * Date: 11-12-7
 * Time: 下午9:35
 */
public class CustomDialog extends Dialog implements View.OnClickListener {
    private TextView mTitle;
    private TextView mMessage;

    protected CustomDialog(Context context) {
        super(context,R.style.upomp_bypay_MyDialog);
        construct(context);
    }

    private void construct(Context context) {
        setContentView(R.layout.custom_dialog);
        mTitle = (TextView) this.findViewById(R.id.custom_dialog_title);
        mMessage = (TextView) this.findViewById(R.id.custom_dialog_message);
        Button mOK = (Button) this.findViewById(R.id.custom_dialog_btn);
        mOK.setOnClickListener(this);
    }

    public void setTitle(String title) {
        mTitle.setText(title);
    }

    public void setMessage(String message) {
        mMessage.setText(message);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.custom_dialog_btn:
                this.dismiss();
                break;
        }
    }

    public static class Builder {
        private CustomDialog dialog;

        public Builder(Context context) {
            dialog = new CustomDialog(context);
        }

        public Builder setTitle(String title) {
            dialog.setTitle(title);
            return this;
        }

        public Builder setMessage(String msg) {
            dialog.setMessage(msg);
            return this;
        }
        public CustomDialog create(){
            return dialog;
        }
    }
}
